export const schema = {
    type: "page",
    title: "消息公告列表",
    body: {
        type: "crud",
        api: "get:/api/news",
        columnsTogglable: false,
        showHeader: false,
        columns: [
            {
                name: "id",
                label: "ID"
            },

            {
                name: "title",
                label: "标题",
                type: "tpl",
                tpl: "<a data-link='/news/edit/${id}'>${title}</a>"
            },


            // {
            //     name: 'content',
            //     label: '跳转方式',
            //     type: "tpl",
            //     tpl: "${content}"
            // },

            {
                name: "photo",
                label: "公告图",
                type: "image",
                popOver: {
                    title: "",
                    body: '<div class="w w-xxl"><img class="w-full" src=${photo} /></div>'
                }
            },


            {
                name: "status",
                width: 80,
                label: "启用",
                type: "map",
                map: {
                    "*": '<span class="label label-default">已禁用</span>',
                    "1": '<span class="label label-success">已启用</span>'
                }
            },

            {
                label: "操作",
                type: "operation",
                width: 180,
                buttons: [
                    {
                        type: "button",
                        size: "xs",
                        level: "info",
                        label: "编辑",
                        actionType: "link",
                        link: "/news/edit/${id}"
                    },

                    {
                        type: "button",
                        size: "xs",
                        label: "禁用",
                        level: "warning",
                        // confirmText: "确定要禁用？",
                        actionType: "ajax",
                        api: "put:/api/news/$id?status=0",
                        visibleOn: "data.status == 1"
                    },

                    {
                        type: "button",
                        size: "xs",
                        label: "启用",
                        level: "success",
                        // confirmText: "确定要启用？",
                        actionType: "ajax",
                        api: "put:/api/news/$id?status=1",
                        visibleOn: "data.status == 0"
                    },
                    {
                        type: "button",
                        size: "xs",
                        label: "置顶",
                        level: "primary",
                        actionType: "ajax",
                        api: "put:/api/news/$id?is_recommend=1",
                        visibleOn: "data.is_recommend == 0"
                    },
                    {
                        type: "button",
                        size: "xs",
                        level: "primary",
                        label: "取消置顶",
                        actionType: "ajax",
                        api: "put:/api/news/$id?is_recommend=0",
                        visibleOn: "data.is_recommend == 1"
                    },
                ]
            }
        ]
    }
};
